﻿Public Class Initialize
    Dim PID() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("pol")
    Public Function Detect() As Boolean

        If PID.Count = 0 Then
            Return False
        Else
            ' if a pol process is detected then it will get the players username
            ' and the ProcessID
            If PID(0).MainWindowTitle.Contains("PlayOnline Viewer") = True Or PID(0).MainWindowTitle = "" Then
                Return False
            Else
                Return True
            End If
        End If
    End Function

    Public Sub CreateHandlers()
        If Detect() = True Then
            ProcessID = PID(0).Id
            WindowerHelper.Keyboard = WindowerKeyboard.CreateKeyboardHelper("WindowerMMFKeyboardHandler_" & ProcessID)
            WindowerHelper.Text = WindowerTextObjects.CreateTextHelper("WindowerMMFTextHandler_" & ProcessID)
            WindowerHelper.Console = WindowerConsole.CreateConsoleHelper("WindowerMMFConsoleHandler_" & ProcessID)
        End If
    End Sub

    Public Sub DeleteHandlers()
        WindowerKeyboard.DeleteKeyboardHelper(WindowerHelper.Keyboard)
        WindowerTextObjects.DeleteTextHelper(WindowerHelper.Text)
        WindowerConsole.DeleteConsoleHelper(WindowerHelper.Console)
    End Sub
End Class